namespace Webbness.Generator.CodeDom

import System
import System.Text.RegularExpressions
import System.IO

internal class LocalDocumentTypeResolver(System.Xml.XmlUrlResolver):

	public def constructor(systemEntry as string):
		self.systemEntry = systemEntry

	protected systemEntry = ''

	public override def GetEntity(absoluteUri as Uri, role as string, ofObjectToReturn as Type) as object:
		re = Regex('(.)*\\.dtd$')
		m as Match = re.Match(absoluteUri.AbsolutePath)
		if true == m.Success:
			return FileStream(systemEntry, FileMode.Open, FileAccess.Read, FileShare.Read)
		return super.GetEntity(absoluteUri, role, ofObjectToReturn)
